package cn.yuanqiao.web.controller.archive.bianyan;

import cn.yuanqiao.archive.bianyan.domain.YqDataGerenKu;
import cn.yuanqiao.archive.bianyan.domain.YqDataZhuantiGern;
import cn.yuanqiao.archive.bianyan.service.IYqDataGerenKuService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.web.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资料资源
 *
 * @ProjectName: ruoyi-modules-system
 * @Package: cn.yuanqiao.web.controller.archive.bianyan
 * @ClassName: YqDataGerenKuController
 * @Author: lenovo
 * @Description: hbWang
 * @Date: 2023/7/5 16:30
 * @Version: 1.0
 */
@RestController
@RequestMapping("/archive/personal/library")
public class YqDataGerenKuController   extends BaseController {
    @Autowired
    private IYqDataGerenKuService yqDataGerenKuService;

    /**
     * 查询资料资源个人库列表
     */
    @PreAuthorize("@ss.hasPermi('archive:personalLibrary:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqDataGerenKu yqDataGerenKu)
    {
        startPage();
        List<YqDataGerenKu> list = yqDataGerenKuService.selectYqDataGerenKuList(yqDataGerenKu);
        return getDataTable(list);
    }


    /**
     * 获取资料资源个人库详细信息
     */
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(yqDataGerenKuService.selectYqDataGerenKuByID(ID));
    }

    /**
     * 新增资料资源个人库
     */
    @PreAuthorize("@ss.hasPermi('archive:personalLibrary:add')")
    @Log(title = "资料资源个人库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqDataGerenKu yqDataGerenKu)
    {
        return toAjax(yqDataGerenKuService.insertYqDataGerenKu(yqDataGerenKu));
    }

    /**
     * 修改资料资源个人库
     */
  //  @PreAuthorize("@ss.hasPermi('archive:KU:edit")
    @Log(title = "资料资源个人库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqDataGerenKu yqDataGerenKu)
    {
        return toAjax(yqDataGerenKuService.updateYqDataGerenKu(yqDataGerenKu));
    }

    /**
     * 删除资料资源个人库
     */
    @PreAuthorize("@ss.hasPermi('archive:personalLibrary:remove')")
    @Log(title = "资料资源个人库", businessType = BusinessType.DELETE)
    @DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable String IDs)
    {
        return toAjax(yqDataGerenKuService.deleteYqDataGerenKuByIDs(IDs));
    }

    /**
     * 根据专题id 查询专题列表
     */
    // @PreAuthorize("@ss.hasPermi('archive:KU:list")
    @PostMapping("/subject/list")
    public TableDataInfo zhuanTiList(@RequestBody YqDataGerenKu yqDataGerenKu)
    {
        startPage();
        List<YqDataGerenKu> list = yqDataGerenKuService.selectYqZhuanTiList(yqDataGerenKu);
        return getDataTable(list);
    }

    /**
     * 添加至专题库
     * @param yqDataZhuantiGern
     * @return
     */
    @PreAuthorize("@ss.hasPermi('archive:personalLibrary:zhuanTiAdd')")
    @Log(title = "新增至专题库", businessType = BusinessType.INSERT)
    @PostMapping("subject/add")
    public AjaxResult zhuanTiAdd(@RequestBody List<YqDataZhuantiGern> yqDataZhuantiGern)
    {
        return toAjax(yqDataGerenKuService.insertYqZhuanTiList(yqDataZhuantiGern));
    }

    /**
     * 退回到个人库
     * @param IDs
     * @return
     */
    @PreAuthorize("@ss.hasPermi('archive:personalLibrary:subject')")
    @Log(title = "退回到个人库", businessType = BusinessType.UPDATE)
    @PutMapping("subject/{IDs}")
    public AjaxResult zhuanTiRemove(@PathVariable String[] IDs)
    {
        return toAjax(yqDataGerenKuService.deleteYqZhuanTiByIDs(IDs));
    }

    /**
     * 移除和添加至公共库
     * @param
     * @return
     */
    @PreAuthorize("@ss.hasPermi('archive:personalLibrary:communalAdd')")
    @Log(title = "移除和添加至公共库", businessType = BusinessType.UPDATE)
    @PostMapping("communal/update")
    public AjaxResult communalUpdate(@RequestParam("IDs") String[] IDs ,@RequestParam("typeState") String typeState)
    {
        return toAjax(yqDataGerenKuService.communalUpdate(IDs,typeState));
    }

}
